#ifndef T3_LenStr
#define T3_LenStr

#include <iostream>
#include <unordered_map>
using namespace std;

//hashmap
class Solution3{
    public:
        int lengthOfLongestSubstring(string s)
        {
            int start(0),end(0),length(0),result(0);
            int sSize=int(s.size());
            unordered_map<char,int> hash;
            while(end<sSize)
            {
                char tmpChar=s[end];

                if(hash.find(tmpChar)!=hash.end()&&hash[tmpChar]>=start)
                {
                    start=hash[tmpChar]+1;
                    length=end-start;
                }
                hash[tmpChar]=end;

                end++;
                length++;
                result=max(result,length);
            }
            std::cout<<"result:"<<result<<endl;
            return result;
        }


};

#endif // !T3_LenStr
